const commandLineArgs = require('command-line-args')
const commandLineUsage = require('command-line-usage')
const chalk = require('chalk')

const optionDefinitions = [
  { name: 'help', alias: 'h', type: Boolean ,description:"帮助"},
  { name: 'client', alias: 'C', type: Boolean ,description:"运行websocket服务器"},
  { name: 'server', alias: 'S', type: Boolean,description:"运行websocket客户端,发送信息,或者验证websocket服务器"}
]

const options = commandLineArgs(optionDefinitions)


const usage = commandLineUsage([
    {
      header: chalk.green('运行Websocket服务器或者websocket客户端'),
      content: ''
    },
    {
      header: 'Options',
      optionList: optionDefinitions
    },
    {
      content: ''
    }
  ])
  

  if((!options.client && !options.server) || options.help){
        console.log(usage)
  }
  if(options.server){

      require("./lib/wsServer")
  } else {
    require("./lib/wsClient")

  }